#include "headfiles.h"

using namespace std;

int trailingZeros(int n) {
/*
    int factor = 10;
    int zeros_factor = 2;
    while ((long long)factor * 10 <= n) {
        factor *= 10;
        zeros_factor = zeros_factor * 10 + 1;
    }
    
    int trailing_zeros = 0;
    int quotient = n / factor;
    int remain = n % factor;
    while (quotient >= 1) {
        trailing_zeros += quotient * zeros_factor;
        zeros_factor = (zeros_factor - 1) / 10;
        factor /= 10;
        if (factor < 10) {
            break;
        }
        quotient = remain / factor;
        remain = remain % factor;
    }
    
    if (remain >= 5) {
        trailing_zeros += 1;
    }
*/
    long long factor;
    int trailing_zeros = 0;
    for (factor = 5; factor <= n; factor *= 5) {
        trailing_zeros += n / factor;
    }
    
    return trailing_zeros;
}


